//
//  gongyingTableViewCell.m
//  BAOASystem
//
//  Created by michael on 2018/3/13.
//  Copyright © 2018年 czd. All rights reserved.
//

#import "gongyingTableViewCell.h"
#import "OALoginViewController.h"
#import "fajianxqViewController.h"
@implementation gongyingTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self)  {
    _imagename = [[UIImageView alloc]init];
        _imagename.frame = CGRectZero;
          [self.contentView addSubview:_imagename]; _label1 = [[UILabel alloc]init];
    _label1.frame = CGRectZero;
    _label1.textColor = [UIColor colorWithHexString:@"484848"];
      [_label1 setFont:[UIFont systemFontOfSize:14]];
       [self.contentView addSubview:_label1];
    
         _label2 = [[UILabel alloc]init];
    _label2.frame = CGRectZero;
                                     _label2.numberOfLines = 0;

    _label2.textColor = [UIColor colorWithHexString:@"a1a1a1"];
      [_label2 setFont:[UIFont systemFontOfSize:13]];
       [self.contentView addSubview:_label2];
    
                _label3 = [[UILabel alloc]init];
    _label3.frame = CGRectZero;
                                     _label3.numberOfLines = 0;

    _label3.textColor = [UIColor colorWithHexString:@"a1a1a1"];
      [_label3 setFont:[UIFont systemFontOfSize:13]];
       [self.contentView addSubview:_label3];
    
                 _label4 = [[UILabel alloc]init];
                                 _label4.numberOfLines = 0;

    _label4.frame = CGRectZero;
    _label4.textColor = [UIColor colorWithHexString:@"a1a1a1"];
      [_label4 setFont:[UIFont systemFontOfSize:13]];
       [self.contentView addSubview:_label4];
_sendbutton = [UIButton buttonWithType:UIButtonTypeCustom];
    [_sendbutton addTarget:self action:@selector(sendaction) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:_sendbutton];
     _qiyebutton =[UIButton buttonWithType:UIButtonTypeCustom];
[_qiyebutton setEnabled:NO];
    [self.contentView addSubview:_qiyebutton];
     _huiyuanbutton =[UIButton buttonWithType:UIButtonTypeCustom];
[_huiyuanbutton setEnabled:NO];
    [self.contentView addSubview:_huiyuanbutton];
       }
return self;

}
- (void)sendaction{
   UIStoryboard * storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];


    if (![[[NSUserDefaults standardUserDefaults]objectForKey:@"autoLogin"]isEqualToString:@"Y"]&&![[DanLi sharedDanLi].stay isEqualToString:@"yes"]) {
      OALoginViewController * loginVC = [storyBoard instantiateViewControllerWithIdentifier:@"LoginVC"];
        UINavigationController * navVC = [[UINavigationController alloc]initWithRootViewController:loginVC];
        loginVC.navigationController.navigationBar.hidden = YES;
                 self.ViewController.view.window.rootViewController = navVC;

}else{
fajianxqViewController *vc = [[fajianxqViewController alloc]init];
vc.hidesBottomBarWhenPushed = YES;

//@property (strong, nonatomic)  NSString *toMemberCompanyId;
//@property (strong, nonatomic)  NSString *toMemberNameId;
//
//@property (strong, nonatomic)  NSString *productId;

        NSDictionary * dic = _dic;
//vc.productId = dic[@"id"];
vc.toMemberNameId = dic[@"userId"];

vc.toMemberCompanyId = dic[@"id"];
[self.ViewController.navigationController pushViewController:vc animated:YES];

}
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (void)layoutSubviews{

[super layoutSubviews];
if (![_dic[@"cppdimg"]isEqual:[NSNull null]]) {

_imagename.frame = CGRectMake(KScreenWidth-130, 10, 120, 120);
    [_imagename sd_setImageWithURL:[NSURL URLWithString:_dic[@"cppdimg"]] placeholderImage:[UIImage imageNamed:@"加载"]];
}else{
_imagename.frame = CGRectMake(KScreenWidth-0, 10, 0, 0);

}
_label1.frame = CGRectMake(10,10, KScreenWidth-_imagename.width-30, 20);
_qiyebutton.backgroundColor = [UIColor clearColor];
[_qiyebutton setImage:[UIImage imageNamed:@"认证企业"] forState:UIControlStateNormal];
[_qiyebutton setTitle:NSLocalizedString(@"商品详情-认证企业", nil) forState:(UIControlState)UIControlStateNormal];
[_qiyebutton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft
                                    imageTitleSpace:0];
_qiyebutton.frame  = CGRectMake(10,_label1.bottom,100, 30);
    _qiyebutton.titleLabel.numberOfLines = 0;

    _qiyebutton.titleLabel.font = [UIFont systemFontOfSize: 12.0];
    _qiyebutton.userInteractionEnabled=NO;
          [_qiyebutton setTitleColor:[UIColor colorWithHexString:@"a1a1a1"] forState:UIControlStateNormal];
 _huiyuanbutton.backgroundColor = [UIColor clearColor];
 _huiyuanbutton.titleLabel.numberOfLines = 0;

[_huiyuanbutton setImage:[UIImage imageNamed:@"会员企业"] forState:UIControlStateNormal];
[_huiyuanbutton setTitle:NSLocalizedString(@"商品详情-会员企业", nil) forState:(UIControlState)UIControlStateNormal];
[_huiyuanbutton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft
                                    imageTitleSpace:0];
_huiyuanbutton.frame  = CGRectMake(_qiyebutton.right+10,_label1.bottom,100, 30);
    _huiyuanbutton.titleLabel.font = [UIFont systemFontOfSize: 12.0];
    _huiyuanbutton.userInteractionEnabled=NO;
              [_huiyuanbutton setTitleColor:[UIColor colorWithHexString:@"a1a1a1"] forState:UIControlStateNormal];


    _label2.frame = CGRectMake(10,_label1.bottom+30, KScreenWidth-_imagename.width-30, 32);
    _label3.frame = CGRectMake(10,_label2.bottom, KScreenWidth-_imagename.width-30, 32);
    _label4.frame = CGRectMake(10,_label3.bottom, KScreenWidth-_imagename.width-30, 32);
     _sendbutton.frame = CGRectMake(10, _label4.bottom, 150, 20);
     [_sendbutton setImage:[UIImage imageNamed:@"我的-联系信"] forState:UIControlStateNormal];
    [_sendbutton setTitle:NSLocalizedString(@"发送信息", nil) forState:UIControlStateNormal];
    _sendbutton.titleLabel.font = [UIFont systemFontOfSize: 12.0];
      [_sendbutton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft  imageTitleSpace:0];
      [_sendbutton setTitleColor:[UIColor colorWithHexString:@"0aa0f6"] forState:UIControlStateNormal];
 _label1.text = [NSString stringWithFormat:@"%@",_dic[@"name"]];

  if([_dic[@"rztype"]isEqual:[NSNull null]]){
_qiyebutton.hidden = YES;
}else{
_qiyebutton.hidden = NO;
}
if([_dic[@"viptype"]isEqual:[NSNull null]]){
_huiyuanbutton.hidden = YES;
}else{
_huiyuanbutton.hidden =  NO;
[_huiyuanbutton setTitle:_dic[@"viptype"] forState:(UIControlState)UIControlStateNormal];
}
   _label2.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"供应商-经营范围", nil),_dic[@"businessScope"]];

  _label3.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"供应商-企业性质", nil),_dic[@"type"]];
         _label4.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"供应商-所在地", nil),_dic[@"areaId"]];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
